<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8"/>
    <title>小程序配置</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <link rel="stylesheet" th:href="@{/css/font.css}"/>
    <link rel="stylesheet" th:href="@{/css/xadmin.css}"/>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a><cite>配置列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form id="form" class="layui-form layui-col-space5" method="post" th:action="@{/wx/admin/config/insert}">
                        <input type="hidden" name="wxMiniAppId" th:value="${wxMiniAppId}" />
                        <input type="hidden" name="type" th:value="${type}" />
                        <div class="layui-inline layui-show-xs-block">
                            <table>
                                <tr>
                                    <td>参数:<input type="text" name="keyName" /></td>
                                    <td>参数值:<input type="text" name="value" /></td>
                                    <td>参数说明:<input type="text" name="keyRemark" /></td>
                                    <td><input type="submit" value="保存" /></td>
                                </tr>
                            </table>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>id</th>
                            <th style="display: none;">小程序id</th>
                            <th>类型</th>
                            <th>类型说明</th>
                            <th>参数</th>
                            <th>参数说明</th>
                            <th>参数值</th>
                            <th>创建时间</th>
                            <th>是否启用</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="config,configStat : ${list}">
                            <td th:text="${config.id}"></td>
                            <td style="display: none;" th:text="${config.wxMiniAppId}"></td>
                            <td th:text="${config.type}"></td>
                            <td th:text="${config.typeRemark}"></td>
                            <td th:text="${config.keyName}"></td>
                            <td th:text="${config.keyRemark}"></td>
                            <td th:text="${config.value}"></td>
                            <td th:text="${#dates.format(config.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td th:text="${config.enable==1?'启用':'未启用'}"></td>
                            <td class="td-manage">
                                <a th:if="${config.enable==0}" title="启用" href="javascript:;"><i class="layui-icon" th:onclick="qiyong([[${config.getId().toString()}]])">启用</i></a>
                                <a th:if="${config.enable==1}" title="停用" href="javascript:;"><i class="layui-icon" th:onclick="tingyong([[${config.getId().toString()}]])">停用</i></a>
                                <a title="删除" href="javascript:;"><i class="layui-icon" th:onclick="deleteById([[${config.getId().toString()}]])">删除</i></a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>layui.use(['laydate', 'form'],
    function() {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    function qiyong(id) {
        $.post("/wx/admin/config/enable/"+id+"/1",function(data,status){
            location.reload();
        });
    }

    function tingyong(id) {
        $.post("/wx/admin/config/enable/"+id+"/0",function(data,status){
            location.reload();
        });
    }

    function deleteById(id) {
        layer.confirm("确定删除此记录？",{btn: ['确定', '取消'], title: "提示"},function () {
            $.post("/wx/admin/config/delete/"+id,function(data,status){
                location.reload();
            });
        });
    }
</script>

</html>